//
//  JDHudUtil.m
//  DaoZiJinFu
//
//  Created by dzjf on 16/10/27.
//  Copyright © 2016年 dzjf. All rights reserved.
//

#import "JDHudUtil.h"
static NSTimeInterval kDefaultHideDelaySeconds = 1.4;
@implementation JDHudUtil

+ (void)showVprogressHUD {
    [SVProgressHUD setDefaultStyle:SVProgressHUDStyleDark];
    [SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeNative];
    [SVProgressHUD show];
}

+ (void)showMessage:(NSString*)msg onView:(UIView *)view hideAfter:(NSTimeInterval)timeSeconds {
    JSHIDEHUD;
    if (!view)view = [UIApplication sharedApplication].delegate.window;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.color = [UIColor blackColor];
    hud.userInteractionEnabled = NO;
    hud.labelText = msg;
    [hud hide:YES afterDelay:timeSeconds];
}
+ (void)showMessage:(NSString*)msg hideAfter:(NSTimeInterval)timeSeconds {
    [JDHudUtil showMessage:msg onView:nil hideAfter:timeSeconds];
}
+ (void)showMessageAndHide:(NSString*)msg {
    [JDHudUtil showMessage:msg hideAfter:kDefaultHideDelaySeconds];
}


+ (void)show {
    UIView *view = [UIApplication sharedApplication].delegate.window;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.color = [UIColor blackColor];
}


+ (void)showText:(NSString *)text {
    UIView *view = [UIApplication sharedApplication].delegate.window;
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.labelText = text;
    hud.color = [UIColor blackColor];
}

+ (void)dismiss {
    [MBProgressHUD hideHUDForView:[UIApplication sharedApplication].delegate.window animated:YES];
}

+ (void)showToView:(UIView *)view {
   [MBProgressHUD showHUDAddedTo:view animated:YES];
}

+ (void)HideToView:(UIView *)view {
   [MBProgressHUD hideHUDForView:view animated:YES];
}

@end
